<HTML><HEAD><TITLE>make_graph(+NNodes, ++EdgeList, -Graph)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">library(graph_algorithms)</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>make_graph(+NNodes, ++EdgeList, -Graph)</H1>
Creates a graph with minimal overhead
<DL>
<DT><EM>NNodes</EM></DT>
<DD>the number of nodes: integer &gt;= 0
</DD>
<DT><EM>EdgeList</EM></DT>
<DD>a (possibly empty) list of e/3 structures in no particular order
</DD>
<DT><EM>Graph</EM></DT>
<DD>will be bound to a graph structure
</DD>
</DL>
<H2>Description</H2>
<P>
    This predicate creates a graph data structure according to the given
    information.  A graph consists of nodes that are numbered from 1 to
    NNodes and directed edges between the nodes. An edge is represented
    by the data structure
<PRE>
	e(Source, Target, EdgeData)
</PRE>
    where Source and Target are integers indicating the start and end
    point of the edge, and EdgeData is an arbitrary data structure
    holding additional information about the edge, e.g. capacity,
    distance, weight, name etc.  The EdgeData field should have the
    same structure for all edges in the graph.  If there is no
    information attached to edges, the field should be set to 1
    for edges between different nodes and to 0 otherwise.
    Several library predicates inspect the EdgeData field or an argument
    of the EdgeData field, e.g. the shortest path predicate can
    use any numeric component of EdgeData as the distance criterion.
    Caution: the distance arguments will be compared using general term
    comparison (see compare/3) and should therefore have the same
    type in all edges (e.g. all integer or all float).
    </P>
<H3>Modes and Determinism</H3><UL>
<LI>make_graph(+, ++, -) is det
</UL>
<H3>Fail Conditions</H3>
Edges contain nonexisting node numbers
<H3>Exceptions</H3>
<DL>
<DT><EM>(6) out of range </EM>
<DD>NNodes is negative
<DT><EM>(4) instantiation fault </EM>
<DD>NNodes or EdgeList are uninstantiated
<DT><EM>(5) type error </EM>
<DD>NNodes is not integral
</DL>
<H2>Examples</H2>
<PRE>
    % the 13-node undirected graph from Sedgewick:Algorithms
    make_graph( 13,
	[ e(1,6,1),e(1,2,1),e(1,7,1),e(3,1,1),e(4,6,1),e(5,4,1),
	  e(6,5,1),e(7,5,1),e(7,10,1),e(7,3,1),e(8,7,1),e(8,9,1),e(9,8,1),
	  e(10,11,1),e(10,12,1),e(10,13,1),e(12,7,1),e(12,13,1),e(13,12,1) ],
        Graph).</PRE>
<H2>See Also</H2>
<A HREF="../../lib/graph_algorithms/make_graph_symbolic-3.html">make_graph_symbolic / 3</A>, <A HREF="../../lib/graph_algorithms/graph_set_nodenames-2.html">graph_set_nodenames / 2</A>, <A HREF="../../lib/graphviz/index.html">library(graphviz)</A>, <A HREF="../../kernel/termcomp/compare-3.html">compare / 3</A>
</BODY></HTML>
